package com.topnav.mc.admin.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topnav.mc.admin.entity.RoleAuthorization;
import com.topnav.mc.admin.entity.bean.RoleAuthorizationBean;
import com.topnav.mc.admin.entity.param.RoleAuthorizationParam;
import com.topnav.mc.base.mc.McMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: kenny
 * @Date: 2024/2/27 10:18
 */
@Mapper
public interface RoleAuthorizationMapper extends McMapper<RoleAuthorization, RoleAuthorizationBean, RoleAuthorizationParam> {

    String commSql = " SELECT ra.*,r.code AS roleCode,r.name AS roleName, a.at_code AS authCode,a.at_name AS authName, " +
            " a.at_path AS authPath, a.parent_id AS authParentId " +
            " FROM mc_role_auth ra " +
            " LEFT JOIN mc_auth a ON ra.auth_id = a.id " +
            " LEFT JOIN mc_role r ON ra.role_id = r.id " +
            " ${ew.customSqlSegment} ";
    @Select(commSql)
    RoleAuthorizationBean selectInfoOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    List<RoleAuthorizationBean> selectInfoList(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    Page<RoleAuthorizationBean> selectInfoPage(Page<RoleAuthorizationParam> page, @Param(Constants.WRAPPER) Wrapper queryWrapper);
}
